#include "widgethost.h"

#include "formresizer.h"
#include "qformwidget.h"

#include <QPainter>

WidgetHost::WidgetHost(QWidget *parent):
    QScrollArea(parent),
    m_formResizer(new FormResizer(this))
{
    setWidget(m_formResizer);
    setFrameStyle(QFrame::NoFrame);
}

WidgetHost::~WidgetHost()
{

}

void WidgetHost::showHandle()
{
    m_formResizer->showHandle();
}

void WidgetHost::hideHandle()
{
    m_formResizer->hideHandle();
}

bool WidgetHost::isHandleVisible()
{
    return m_formResizer->isHandleVisible();
}

void WidgetHost::setFormWidget(QFormWidget *widget)
{
    m_formwidget=widget;
    m_formResizer->setWidget(widget);
}

QFormWidget *WidgetHost::formWidget()
{
    return m_formwidget;
}

void WidgetHost::updateFormGeometry()
{
    m_formResizer->updateFormGeometry();
}

void WidgetHost::paintEvent(QPaintEvent *)
{
    QPainter p(viewport());

    p.fillRect(this->rect(),Qt::white);
}
